package com.yckj.day03;

import java.util.Scanner;

/**
 * TODO 任务1  验证用户的用户名和密码是否正确，提示用户登录,直到输入正确的用户”admin”和密码”123”为止
 *
 * @author shengyuee
 * @version 1.0
 * 2025/7/18 15:42
 */
public class EqualsDemo {
    public static void main(String[] args) {
        String username = "admin";
        String password = "123";
        Scanner scan = new Scanner(System.in);
        while(true){
            System.out.print("请输入用户名：");
            String uname = scan.next();
            System.out.print("请输入密码：");
            String pwd = scan.next();
            if(username.equals(uname) && password.equals(pwd)){
                System.out.println("登录成功");
                break; // 跳出循环
            }else{
                System.out.println("用户名或密码错误");
                scan.nextLine();
                continue;
            }
        }

    }
}
